package org.weasel.business;

import java.sql.Time;
import java.util.ArrayList;

public class UserStory {
	private String id;
	private String description;
	private String name;
	private String generatedDate;
	private String finishedDate;
	private Time estimatedTime;
	private Time usedTime;
	private int risk;
	private int businessValue;
	private boolean isExperimental;
	private ArrayList<Developer> developers;
	private ArrayList<Task> tasks;
	
	
	public void setGeneratedDate(String generatedDate) {
		this.generatedDate = generatedDate;
	}


	public UserStory(String id, String name, String generatedDate, String finishedDate, String description, Time estimatedTime, Time usedTime, int risk, int businessValue, boolean isExperimental, ArrayList<Developer> developers, ArrayList<Task> tasks) {
		this.id = id;
		this.description = description;
		this.name = name;
		this.generatedDate = generatedDate;
		this.finishedDate = finishedDate;
		this.estimatedTime = estimatedTime;
		this.usedTime = usedTime;
		this.risk = risk;
		this.businessValue = businessValue;
		this.isExperimental = isExperimental;
		if (developers != null)
			this.developers = developers;
		else
			this.developers = new ArrayList<Developer>();
		
		if (tasks != null)
			this.tasks = tasks;
		else
			this.tasks = new ArrayList<Task>();
		
	}


	public int getBusinessValue() {
		return businessValue;
	}


	public void setBusinessValue(int businessValue) {
		this.businessValue = businessValue;
	}


	public String getDescription() {
		return description;
	}


	public void setDescription(String description) {
		this.description = description;
	}


	public ArrayList<Developer> getDevelopers() {
		return developers;
	}


	public void setDevelopers(ArrayList<Developer> developers) {
		this.developers = developers;
	}


	public Time getEstimatedTime() {
		return estimatedTime;
	}


	public void setEstimatedTime(Time estimatedTime) {
		this.estimatedTime = estimatedTime;
	}


	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public int getRisk() {
		return risk;
	}


	public void setRisk(int risk) {
		this.risk = risk;
	}


	public ArrayList<Task> getTasks() {
		return tasks;
	}


	public void setTasks(ArrayList<Task> tasks) {
		this.tasks = tasks;
	}


	public Time getUsedTime() {
		return usedTime;
	}


	public void setUsedTime(Time usedTime) {
		this.usedTime = usedTime;
	}
	
	public void addDeveloper(Developer developer){
		developers.add(developer);
	}
	
	public void removeDeveloper(String id){
		Developer d;
		for (int i =0; i<developers.size(); i++){
			d = developers.get(i);
			if (d.getId().equals(id)){
				developers.remove(i);
				return;
			}
		}
	}
	
	public Developer getDeveloper(String id){
		for (Developer developer : developers) {
			if (developer.getId().equals(id))
				return developer;			
		}
		return null;
	}
	
	public void addTask(Task task){
		tasks.add(task);
	}
	
	public void removeTask(String id){
		Task t;
		for (int i =0; i<tasks.size(); i++){
			t = tasks.get(i);
			if (t.getId().equals(id)){
				tasks.remove(i);
				return;
			}
		}
	}

	public Task getTask(String id){
		for (Task task : tasks) {
			if (task.getId().equals(id))
				return task;
		}
		return null;
	}


	public boolean isExperimental() {
		return isExperimental;
	}


	public String getGeneratedDate() {
		return generatedDate;
	}


	public String getFinishedDate() {
		return finishedDate;
	}


	public void setFinishedDate(String finishedDate) {
		this.finishedDate = finishedDate;
	}
	
	
}
